
clear ;clc;
load('FeatureAu_1stMarkovT3.mat');
load('FeatureSp_1stMarkovT3.mat');
pau=randperm(933);
psp=randperm(912);
v_num=2;
indtestAu=pau(1:round(933/v_num));
indtestSp=psp(1:round(912/v_num));
indtrainAu=pau(round(933/v_num)+1:end);
indtrainSp=psp(round(912/v_num)+1:end);
Train=[FeatureAu(indtrainAu,:);FeatureSp(indtrainSp,:)];
Test=[FeatureAu(indtestAu,:);FeatureSp(indtestSp,:)];
label_test=[ones(round(933/v_num),1);ones(round(912/v_num),1)-2];
label_train=[ones(933-round(933/v_num),1);ones(912-round(912/v_num),1)-2];
meantra=mean(Train);
stdtra=std(Train);
IrisData=(Train-repmat(meantra,size(Train,1),1))./repmat(stdtra,size(Train,1),1);
Test=(Test-repmat(meantra,size(Test,1),1))./(repmat(stdtra,size(Test,1),1));
sigma=5.5;%
dataGDA=BuildGDA(IrisData,[length(indtrainAu),length(indtrainSp)],sigma);			% Build GDA solution
tmp1=gdamapping(IrisData,IrisData,dataGDA,1,sigma);
valAu=mean(tmp1(1:length(indtrainAu)));
valSp=mean(tmp1(length(indtrainAu)+1:end));


tmp=gdamapping(Test,IrisData,dataGDA,1,sigma);	
Tp=sum(abs(tmp(1:length(indtestAu))-valAu)<abs(tmp(1:length(indtestAu))-valSp))/length(indtestAu);
Tn=sum(abs(tmp(length(indtestAu)+1:end)-valAu)>=abs(tmp(length(indtestAu)+1:end)-valSp))/length(indtestSp);
Acc=(sum(abs(tmp(1:length(indtestAu))-valAu)<abs(tmp(1:length(indtestAu))-valSp))+sum(abs(tmp(length(indtestAu)+1:end)-valAu)...
    >=abs(tmp(length(indtestAu)+1:end)-valSp)))/length(label_test);
disp('ok')
